package com.wms.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wms.entity.WUserStore;
import com.wms.vo.WUserStoreInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 用户-仓库权限表(WUserStore)表数据库访问层
 *
 * @author Li Xiaoyu
 * @since 2023-10-20 17:21:21
 */
@Mapper
public interface WUserStoreDao extends BaseMapper<WUserStore> {
    @Select("select a.id,b.username,c.`name`,a.creator,a.mender,a.create_time,a.update_time,a.note " +
            "from w_user_store a,w_user b,w_store c where a.uid=b.user_id and a.sid=c.store_id")
    List<WUserStoreInfo> selectUserStoreInfo();
    @Select("select a.id,a.sid,c.`name` " +
            "from w_user_store a,w_store c where a.sid=c.store_id and a.uid=#{id}")
    List<WUserStoreInfo> selectByUserId(Integer id);
    @Update("update w_user_store set uid=(select user_id from w_user where username = #{username}),sid=(select store_id from w_store where name = #{name})," +
            "creator=#{creator},mender=#{mender},create_time=#{createTime},update_time=#{updateTime},note=#{note} where id=#{id}")
    int updateByVo(WUserStoreInfo wUserStoreInfo);
}

